# from new_func.print_log import log
from PyQt5.QtCore import QThread


class Worker(QThread):

    def __init__(self, func):
        super(Worker, self).__init__()
        self.func = func

    def run(self):
        self.func()  # 执行你的任务
        print(f"{self.func}线程启动")
        # log.info("\033[0;32m" + '线程启动' + "\033[0m")
        # self.finished.emit("1")

    def stop(self):
        # 停止线程的方法
        self.quit()
        self.wait()
        print(f"{self.func}线程结束")
        # log.info("\033[0;32m" + '线程结束' + "\033[0m")
